package com.bdqn.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bdqn.mapper.RoleManageMapper;
import com.bdqn.model.RoleList;
import com.bdqn.service.RoleManageService;

@Service("roleManageService")
public class RoleManageServiceImpl implements RoleManageService{

	@Autowired
	private RoleManageMapper roleManageMapper;
	
	@Override
	public List<RoleList> queryRole() {
		List<RoleList> role=roleManageMapper.queryRole();
		return role;
	}

	@Override
	public boolean updateData(String roleName, String state) {
		Date day=new Date();
		SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		String createDate=df.format(day);
		int row =roleManageMapper.updateData(roleName,state,createDate);
		if(row == 1) {
			return true;
		}
		return false;
	}

	@Override
	public boolean deleteData(String roleName) {
		int row =roleManageMapper.deleteDate(roleName);
		if(row == 1) {
			return true;
		}
		return false;
	}

	@Override
	public boolean addRoleData(String roleName, String state) {
		Date day=new Date();
		SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		String createDate=df.format(day);
		int row=roleManageMapper.addRoleData(roleName,state,createDate);
		if(row == 1) {
			return true;
		}
		return false;
	}

}
